#!/usr/bin/python3
# -*- coding: UTF-8 -*-
"""
自定义异常：
    - 程序可以通过创建新的异常类来命名它们自己的异常；
    - 异常通常应该直接或间接地从 Exception 类派生；
    - 大多数异常名称以 Error 结尾，类似于标准异常的命名；
"""


class Error(Exception):
    """Base class for exceptions in this module."""
    pass


class InputError(Error):
    """Exception raised for errors in the input.

    Attributes:
        expression -- input expression in which the error occurred
        message -- explanation of the error
    """

    def __init__(self, expression, message):
        self.expression = expression
        self.message = message


class TransitionError(Error):
    """Raised when an operation attempts a state transition that's not allowed.

    Attributes:
    previous -- state at beginning of transition
    next -- attempted new state
    message -- explanation of why the specific transition is not allowed
    """

    def __init__(self, previous, next, message):
        self.previous = previous
        self.next = next
        self.message = message

